package learning.objectStream;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.io.Serializable;

public class ObjectStream1 {
	public static void main(String[] args) {
		try {
			ObjectOutputStream oos = new ObjectOutputStream(
					new FileOutputStream("myfile/my.txt"));
			oos.writeObject("I come from China!");
			oos.writeBoolean(true);
			oos.writeObject(new Dog("Tiger","yellow"));
			// byte[] buf="it is not from a fool".getBytes();
			// oos.write(buf);
			oos.flush();
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

}
class Dog implements Serializable{
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getColor() {
		return color;
	}
	public void setColor(String color) {
		this.color = color;
	}
	private String name;
	private String color;
	public Dog(String name, String color) {
		super();
		this.name = name;
		this.color = color;
	}
	@Override
	public String toString() {
		// TODO Auto-generated method stub
		return this.getName()+"  "+this.getColor();
	}
	
}